//
//  RecommendCycleView.swift
//  swiftDemo
//
//  Created by Gerry on 2021/12/7.
//

import Foundation
import RxCocoa

class RecommendCycleView : UIView {
    private lazy var collectionView : UICollectionView = { [weak self] in
        let layout = UICollectionViewFlowLayout()
        layout.itemSize = CGSize(width: kScreenW, height: 150)
        let collectionView = UICollectionView.init(frame: self?.bounds ?? CGRect.zero, collectionViewLayout: layout)
        collectionView.dataSource = self
        collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "cell")
        return collectionView
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

extension RecommendCycleView {
    func setupUI() {
        self.addSubview(collectionView)
    }
}

extension RecommendCycleView : UICollectionViewDataSource {
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 10
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier:"cell", for: indexPath)
        let lab = UILabel.init(frame: CGRect.init(x: 10, y: 10, width: 60, height: 30))
        lab.font = UIFont.systemFont(ofSize: 14)
        lab.textColor = UIColor.orange
        cell.contentView.addSubview(lab)
        return cell
    }
}
